//
//  NewLoginViewController.m
//  mendianjieke
//
//  Created by 响当当 on 11/15/19.
//  Copyright © 2019 dongzheng. All rights reserved.
//

#import "NewLoginViewController.h"
#import "NewLoginView.h"
#import "ChoseIndustryView.h"

@interface NewLoginViewController ()
@property (nonatomic, strong)NewLoginView *newLoginView;
@property (nonatomic, strong)ChoseIndustryView *industeryView;
@end

@implementation NewLoginViewController
- (NewLoginView *)newLoginView
{
    if (!_newLoginView)
    {
        _newLoginView = [[NewLoginView alloc]initWithFrame:CGRectMake(0,NAVIBAR_HEIGHT,SCREEN_WIDTH,SCREEN_HEIGHT - NAVIBAR_HEIGHT)];
        [_newLoginView getType:self.type];
        WeakSelf(self)
        _newLoginView.changeToIndustryViewBlock = ^{
            [weakSelf completeIndustry];
        };
    }
    return _newLoginView;
}

- (ChoseIndustryView *)industeryView
{
    if (!_industeryView)
    {
        _industeryView = [[ChoseIndustryView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH,NAVIBAR_HEIGHT,SCREEN_WIDTH,SCREEN_HEIGHT-NAVIBAR_HEIGHT)];
    }
    return _industeryView;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self setTitle:@"导购天眼"];
    self.viewType = 0;

    [self.view addSubview:self.newLoginView];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}

#pragma mark - method
- (void)completeIndustry
{
    [self.view addSubview:self.industeryView];

    [UIView animateWithDuration:0.2 animations:^{
        [self.newLoginView setX:-SCREEN_WIDTH];
        [self.industeryView setX:0];
    } completion:^(BOOL finished) {
        [self setTitle:@"请选择行业"];
        [self getIndustry];
        [self cancelBackBtn];
    }];
}

- (void)getIndustry
{
    
    NSDictionary *pramaters = @{
        
                                };

    [infoManager getIndustryInfo:pramaters
                      sucess:^(id  _Nonnull acceptData) {
                        [self.industeryView getDate:acceptData];
                      }
                        fail:^(NSError * _Nullable error) {
                            
                        }];
}

@end
